home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWNotifn / Include / FWRecevr.h < prev   
Encoding:
Text File  |  1996-04-25  |  2.9 KB  |  102 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWRecevr.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWRECEVR_H
  11. #define FWRECEVR_H
  12.  
  13. #ifndef FWINTERE_H
  14. #include "FWIntere.h"
  15. #endif
  16.  
  17. #ifndef FWTCOLL_H
  18. #include "FWTColl.h"
  19. #endif
  20.  
  21. #ifndef __SOM__
  22. #include <som.xh>
  23. #endif
  24.  
  25. //========================================================================================
  26. // Foward declarations
  27. //========================================================================================
  28.  
  29. class FW_CNotification;
  30. class FW_CNotifier;
  31.  
  32. //========================================================================================
  33. // CLASS FW_MReceiver
  34. //========================================================================================
  35.  
  36. class FW_MReceiver
  37. {
  38. public:
  39.     FW_DECLARE_CLASS
  40.     FW_DECLARE_AUTO(FW_MReceiver)
  41.     friend class FW_CReceiverInterestIterator;
  42.     
  43. public:
  44.     FW_MReceiver();
  45.     virtual ~FW_MReceiver();
  46.  
  47.     virtual void    HandleNotification(Environment* ev, const FW_CNotification& notification) = 0;
  48.     
  49.     void            AddInterest(const FW_CInterest& interest);
  50.     void            RemoveAllInterests();
  51.     void            RemoveInterest(const FW_CInterest& interest);
  52.     
  53.     void            AddNotifier(FW_MNotifier* notifier, FW_Message msg);
  54.     void            RemoveNotifier(FW_MNotifier* notifier, FW_Message msg);
  55.     
  56.     void            Connect();
  57.     void            Disconnect();
  58.     
  59.     FW_Boolean        IsConnected() const;
  60.  
  61. private:
  62.     FW_Boolean                            fIsConnected;
  63.     FW_TOrderedCollection<FW_CInterest>    fInterestList;
  64. };
  65.  
  66. //----------------------------------------------------------------------------------------
  67. // FW_MReceiver::IsConnected
  68. //----------------------------------------------------------------------------------------
  69.  
  70. inline FW_Boolean FW_MReceiver::IsConnected() const
  71. {
  72.     return fIsConnected;
  73. }
  74.  
  75. //----------------------------------------------------------------------------------------
  76. // FW_MReceiver::AddNotifier/RemoveNotifier
  77. //----------------------------------------------------------------------------------------
  78.  
  79. inline void FW_MReceiver::AddNotifier(FW_MNotifier* notifier, FW_Message msg)
  80. {
  81.     AddInterest(FW_CInterest(notifier, msg));
  82. }
  83.  
  84. inline void FW_MReceiver::RemoveNotifier(FW_MNotifier* notifier, FW_Message msg)
  85. {
  86.     RemoveInterest(FW_CInterest(notifier, msg));
  87. }
  88.  
  89. //========================================================================================
  90. //    class FW_CReceiverInterestIterator
  91. //========================================================================================
  92.  
  93. class FW_CReceiverInterestIterator : public FW_TOrderedCollectionIterator<FW_CInterest>
  94. {
  95. public:
  96.     FW_CReceiverInterestIterator(FW_MReceiver* receiver) :
  97.         FW_TOrderedCollectionIterator<FW_CInterest>(&receiver->fInterestList) {}
  98.     ~FW_CReceiverInterestIterator() {}
  99. };
  100.  
  101. #endif
  102.